package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.TransportOperateLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * created by wangjunfu on 2021-02-24 15:59:46
 */
public class TransportOperateLogDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(TransportOperateLogDao.class);

    public TransportOperateLog insert(final TransportOperateLog transportOperateLog) {
        insert("TransportOperateLog.insert", transportOperateLog);
        return transportOperateLog;
    }

    public Boolean updateInfoById(final TransportOperateLog transportOperateLog) {
        return update("TransportOperateLog.updateInfoById", transportOperateLog) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("TransportOperateLog.updateInfoByQuery", query) > 0;
    }

    public TransportOperateLog selectById(final Integer id, final Integer entId) {
        Query query = Query.noPage();
        query.put("id", id);
        query.put("entId", entId);
        return queryForObject("TransportOperateLog.selectById", query);
    }

    public List<TransportOperateLog> selectByQuery(final Query query) {
        return queryForList("TransportOperateLog.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("TransportOperateLog.countByQuery", query);
    }

    public Boolean deleteById(final Integer id, final Integer entId) {
        TransportOperateLog transportOperateLog = new TransportOperateLog();
        //transportOperateLog.setDeleteFlag(1);
        transportOperateLog.setId(id);
        transportOperateLog.setEntId(entId);

        return update("TransportOperateLog.updateInfoById", transportOperateLog) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("TransportOperateLog.deleteById", query) > 0;
    }
}